<template>
  <div v-if="infoform === 'InformationCollection'">
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <h3>信息采集表单</h3>
      <el-divider></el-divider>

      <el-form-item
        label="建设类型"
        :label-width="formLabelWidth"
        prop="gConstructionType"
      >
        <el-select
          v-model="form.gConstructionType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gConstructionTypeList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="违法建筑类型"
        :label-width="formLabelWidth"
        prop="gIllegalType"
      >
        <el-select
          v-model="form.gIllegalType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gIllegalTypeList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="建设主体"
        :label-width="formLabelWidth"
        prop="gConstruction"
      >
        <el-select
          v-model="form.gConstruction"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gConstructionList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="主体名称" :label-width="formLabelWidth">
        <el-input
          v-model="form.gMainName"
          placeholder="请输入主体名称"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item label="进度情况" :label-width="formLabelWidth">
        <el-select
          v-model="form.gProgress"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gProgressList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="情况描述"
        :label-width="formLabelWidth"
        prop="gDescribe"
      >
        <el-input
          type="textarea"
          v-model="form.gDescribe"
          class="resizeNone"
          placeholder="描述信息：现在已经... ..."
        ></el-input>
      </el-form-item>

      <!-- action="http://192.168.1.169:8091/uploadExport/upLoadImageFile"
        
            :headers="headers"
       -->
      <el-form-item label="照片" :label-width="formLabelWidth">
        <el-upload
          class="upload-demo"
          action=""
          :http-request="handlephotoBox"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="imageJson"
          list-type="picture"
        >
          <!-- <el-button v-if="jbTable === true" size="small" type="success"
            >点击上传</el-button
          > -->
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
      </el-form-item>

      <!-- <el-form-item label="佐证材料" :label-width="formLabelWidth">
        <el-upload
          class="upload-demo"
          action=""
          :http-request="photoBoxCL"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="fjJson"
          list-type="picture"
        >
          <el-button v-if="jbTable === true" size="small" type="success"
            >点击上传</el-button
          >
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
      </el-form-item> -->

      <el-form-item>
        <div v-if="jbTable === true">
          <!-- <el-button type="success" @click="onSubmit('form')"
            >公众上传</el-button
          > -->

          <el-button type="success" @click="CundealForm('form')"
            >处理</el-button
          >
          <el-button type="warning" @click="report0('form')">上报</el-button>

          <!-- <el-button type="success" @click="dealForm('form')">处理</el-button>
          <el-button type="warning" @click="report('form')">上报</el-button> -->
        </div>

        <div v-if="jbTable === false">
          <el-button type="success" @click="determine('form')"
            >判定虚假信息</el-button
          >
          <el-button type="warning" @click="trueDeal('form')"
            >属实，现场处理</el-button
          >

          <el-button @click="toBack">退出</el-button>
          <div v-if="jbTable === false"></div>
        </div>
      </el-form-item>
    </el-form>

    <el-dialog title="处理表单" :visible.sync="HandleForm" width="40%">
      <handle-form
        :formData1="formData1"
        @toBack="toBack"
        @Handle="Handle"
      ></handle-form>
    </el-dialog>
  </div>

  <div v-else-if="infoform === 'PatrolProblem'">
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <h3
        v-if="
          activeName !== 'third' &&
          activeName !== 'fourth' &&
          activeName !== 'second'
        "
      >
        问题处理表单
      </h3>
      <h3
        v-if="
          activeName === 'third' ||
          activeName === 'fourth' ||
          activeName === 'second'
        "
      >
        巡视问题表单
      </h3>
      <el-divider></el-divider>

      <!-- <el-form-item
        label="信息类型"
        :label-width="formLabelWidth"
        prop="gInfoType"
      >
        <el-select
          v-model="form.gInfoType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gInfoTypeList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item> -->

      <el-form-item
        label="建设类型"
        :label-width="formLabelWidth"
        prop="gConstructionType"
      >
        <el-select
          v-model="form.gConstructionType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gConstructionTypeList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="违法建筑类型"
        :label-width="formLabelWidth"
        prop="gIllegalType"
      >
        <el-select
          v-model="form.gIllegalType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gIllegalTypeList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="建设主体"
        :label-width="formLabelWidth"
        prop="gConstruction"
      >
        <el-select
          v-model="form.gConstruction"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gConstructionList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="主体名称" :label-width="formLabelWidth">
        <el-input
          v-model="form.gMainName"
          placeholder="请输入主体名称"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item label="进度情况" :label-width="formLabelWidth">
        <el-select
          v-model="form.gProgress"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="item in gProgressList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        label="情况描述"
        :label-width="formLabelWidth"
        prop="gDescribe"
      >
        <el-input
          type="textarea"
          v-model="form.gDescribe"
          class="resizeNone"
          placeholder="描述信息：现在已经... ..."
        ></el-input>
      </el-form-item>

      <el-form-item label="照片" :label-width="formLabelWidth">
        <el-upload
          class="upload-demo"
          action=""
          :http-request="photoBox"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="imageJson"
          list-type="picture"
        >
          <el-button size="small" type="success">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
      </el-form-item>

      <!-- <el-form-item label="佐证材料" :label-width="formLabelWidth">
        <el-upload
          class="upload-demo"
          action=""
          :http-request="photoBoxCL"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="fjJson"
          list-type="picture"
        >
          <el-button size="small" type="success">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
      </el-form-item> -->

      <div
        v-show="
          activeName === 'five' ||
          activeName === 'fourth' ||
          activeName === 'third' ||
          (activeName === 'second' && glevel !== 2)
        "
      >
        <el-divider></el-divider>
        <el-form-item
          label="处理措施"
          :label-width="formLabelWidth"
          prop="gClcs"
        >
          <el-select
            v-model="form.gClcs"
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in gClcsList"
              :key="item.typeId"
              :label="item.typeName"
              :value="item.typeId"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item
          label="处理期限"
          :label-width="formLabelWidth"
          prop="gTimelimit"
        >
          <el-select
            v-model="form.gTimelimit"
            @change="gTimelimitChange"
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in gTimelimitList"
              :key="item.typeId"
              :label="item.typeName"
              :value="item.typeId"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="到期时间" :label-width="formLabelWidth">
          <el-input
            v-model="form.gDueTime"
            placeholder="请输入处理期限"
            autocomplete="off"
            disabled
          ></el-input>
        </el-form-item>

        <el-form-item
          label="处理说明"
          :label-width="formLabelWidth"
          prop="gDealNote"
        >
          <el-input
            type="textarea"
            v-model="form.gDealNote"
            class="resizeNone"
            placeholder=""
          ></el-input>
        </el-form-item>
      </div>

      <el-form-item
        label="指导意见"
        :label-width="formLabelWidth"
        prop="guideNote"
        v-show="
          activeName !== 'first' &&
          activeName !== 'five' &&
          activeName !== 'third'
        "
      >
        <el-input
          v-model="form.guideNote"
          placeholder="在操作'指导办理'时请输入指导意见 其他时候无需输入指导意见"
          autocomplete="off"
          :disabled="guideNoteTrF"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button
          v-if="activeName === 'first' && glevel === 2"
          type="success"
          @click="dealForm('form')"
          >处理</el-button
        >

        <!-- <el-button
          v-if="activeName === 'first' && glevel !== 2"
          type="success"
          @click="dealPassForm('form')"
          >处理</el-button
        > -->

        <el-button
          v-if="activeName === 'second' || activeName === 'fourth'"
          type="success"
          @click="dealPassForm('form')"
          >处理</el-button
        >
        <el-button
          v-show="activeName !== 'five'"
          type="warning"
          @click="report('form')"
          >上报</el-button
        >

        <el-button
          v-if="activeName !== 'first' && glevel !== 2 && activeName !== 'five'"
          type="danger"
          :disabled="disabledTrF"
          @click="zdSubmit(form)"
          >指导办理</el-button
        >

        <el-button @click="toBack">退出</el-button>
      </el-form-item>
    </el-form>

    <el-dialog title="处理表单" :visible.sync="HandleForm" width="40%">
      <handle-form
        :formData1="formData1"
        @Handle="Handle"
        @toBack="toBack"
      ></handle-form>
    </el-dialog>

    <el-dialog title="指导表单" :visible.sync="HandleForm1" width="40%">
      <el-form
        ref="zdFormData"
        :model="zdFormData"
        :rules="zdFormDataRules"
        label-width="80px"
      >
        <!-- <el-form-item
          label="指导意见"
          :label-width="formLabelWidth5"
          prop="guideNote"
        >
          <el-input
            v-model="zdFormData.guideNote"
            placeholder="请输入指导意见"
            autocomplete="off"
          ></el-input>
        </el-form-item>

        <el-form-item label="备注" :label-width="formLabelWidth5" prop="gDqsj">
          <el-input
            type="textarea"
            v-model="zdFormData.gDqsj"
            class="resizeNone"
            placeholder=""
          ></el-input>
        </el-form-item> -->

        <el-form-item style="text-align: center">
          <el-button type="success" @click="zdSubmit(zdFormData)"
            >保存</el-button
          >
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  tzzCommonSave,
  tzzCommonSubmit,
  tzzNoSh,
  tzzfindById,
  tzzPatrolSave,
  setDispose,
  setTask,
  setGuide,
  upLoadImageFile,
} from '@/api/grid'

import axios from 'axios'
import cookies from 'js-cookie'

import HandleForm from '@/views/dailyOffice/components/HandleForm.vue'

export default {
  name: 'infoForm',
  components: { HandleForm },
  props: {
    formData: {
      type: Object,
      default: () => {},
    },
    jbTable: {
      type: Boolean,
      default: () => true,
    },
    gTmpId: {
      type: String,
      default: () => '10',
    },
    activeName: {
      type: String,
      default: () => '1',
    },
    // infoform: 'InformationCollection', //切换表单
    infoform: {
      type: String,
      default: () => 'InformationCollection',
    },
    formLabelWidth5: '150px',
  },
  data() {
    return {
      formLabelWidth: '150px',
      // gInfoTypeList: [
      //   {
      //     typeId: '1',
      //     typeName: '违规占用耕地建房',
      //   },
      //   {
      //     typeId: '2',
      //     typeName: '无手续翻建',
      //   },
      // ],
      gConstructionTypeList: [
        {
          typeId: '1',
          typeName: '住宅类',
        },
        {
          typeId: '2',
          typeName: '公共服务类',
        },
        {
          typeId: '3',
          typeName: '产业类',
        },
      ],
      gIllegalTypeList: [
        {
          typeId: '1',
          typeName: '违规占用耕地建房',
        },
        {
          typeId: '2',
          typeName: '无手续翻建',
        },
      ],
      gConstructionList: [
        {
          typeId: '1',
          typeName: '个人',
        },
        {
          typeId: '2',
          typeName: '企业',
        },
        {
          typeId: '3',
          typeName: '其他',
        },
      ],
      gProgressList: [
        {
          typeId: '1',
          typeName: '地表平整',
        },
        {
          typeId: '2',
          typeName: '基础开挖',
        },
        {
          typeId: '3',
          typeName: '主体施工',
        },
      ],
      glevel: '',
      gClcsList: [
        {
          typeId: '1',
          typeName: '停工',
        },
        {
          typeId: '2',
          typeName: '恢复原貌',
        },
        {
          typeId: '3',
          typeName: '补办手续',
        },
      ],
      gTimelimitList: [
        {
          typeId: '1',
          typeName: '3天',
        },
        {
          typeId: '2',
          typeName: '5天',
        },
        {
          typeId: '3',
          typeName: '10天',
        },
      ],

      //  headers="multipart/form-data"
      headers: {
        token: cookies.get('token'),
        ContentType: 'multipart/form-data',
      },
      //表单
      form: {
        // gInfoType: '',
        gConstructionType: '',
        gIllegalType: '',
        gConstruction: '',
        gMainName: '',
        gProgress: '',
        gDescribe: '',
        gWhether: '', //信息是否属实
        button: '', //按钮处理或上报
        gFrequency: null,
        code: '130423100042',
        // 处理表单参数
        gDueTime: '',
        gTimelimit: '',
        gDqsj: '',
        gDealNote: '',
        guideNote: '', //指导意见
        gClcs: '', //处理措施
      },
      zdFormData: {
        guideNote: '',
        gDqsj: '',
      },
      zdFormDataRules: {},
      disabledTrF: false, //指导办理处理置灰
      guideNoteTrF: false, //指导意见
      rules: {
        //规则
        gInfoType: [
          { required: true, message: '请输入信息类型', trigger: 'blur' },
        ],
        gConstructionType: [
          { required: true, message: '请输入信息类型', trigger: 'blur' },
        ],
        gConstruction: [
          { required: true, message: '请输入建设主体', trigger: 'blur' },
        ],
        gIllegalType: [
          { required: true, message: '请输入违法建筑类型', trigger: 'blur' },
        ],
        gDescribe: [
          { required: true, message: '请输入描述信息', trigger: 'blur' },
        ],
      },
      formData1: {},
      imageJson: [
        // {
        //   name: 'food.jpeg',
        //   url:
        //     'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
        // },
        // {
        //   name: 'food2.jpeg',
        //   url:
        //     'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
        // },
      ],
      fjJson: [],
      // infoform: 'InformationCollection', //切换表单
      HandleForm: false, //处理表单显隐
      HandleForm1: false,
    }
  },
  computed: {},
  watch: {
    // infoform:function(v){
    //   if(this.)
    // }
  },
  beforeMount() {
    this.glevel = JSON.parse(sessionStorage.userInfo).glevel

    if (this.formData) {
      if (this.formData.imageJson) {
        this.imageJson = this.formData.imageJson
      }
    }

    // console.log(this.formData)
    if (this.formData) {
      // 如果有到期时间

      if (this.formData.gFrequency) {
        if (this.formData.gFrequency > 1) {
          this.disabledTrF = true
        }
      }
    }

    if (this.jbTable === false) {
      this.form = this.formData
    }
  },
  mounted() {},
  methods: {
    toBack() {
      this.$emit('toBack')
    },
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePreview(file) {
      console.log(file)
    },
    handlephotoBox(param) {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })

      let formImg = new FormData()

      formImg.append('upload', param.file)

      // axios({
      //   method: 'post',
      //   url: 'http://192.168.1.169:8091/uploadExport/upLoadImageFile',
      //   headers: {
      //     'Content-Type': 'multipart/form-data',
      //   },
      //   data: formImg,
      // }).then((res) => {})

      upLoadImageFile(formImg)
        .then((res) => {
          loading.close()
          this.$message({
            message: res.message,
            type: 'success',
          })
        })
        .catch((err) => {
          console.log(err)
          loading.close()
        })
    },
    photoBox(params) {
      const file = params.file
      const forml = new FormData()
      // 文件对象
      forml.append('file', file)
      // 本例子主要要在请求时添加特定属性，所以要用自己方法覆盖默认的action
      // form.append('clientType', 'xxx')
      // 项目封装的请求方法，下面做简单介绍
    },
    photoBoxCL(params) {},
    // 公众上传
    onSubmit(form) {
      this.$refs[form].validate((valid) => {
        if (valid) {
          // console.log(this.form)

          const loading = this.$loading({
            lock: true,
            text: 'Loading',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)',
          })

          tzzCommonSave(this.form)
            .then((res) => {
              loading.close()
              this.$message({
                message: res.message,
                type: 'success',
              })
              this.form = {}
              this.$router.push({ path: '/dailyOffice' })
            })
            .catch((err) => {
              console.log(err)
              loading.close()
            })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    // 日常巡办-处理
    CundealForm(form) {
      this.$refs[form].validate((valid) => {
        if (valid) {
          // console.log(this.form)
          this.formData1 = this.form
          // this.formData1.dataMap = 'UP'
          this.formData1.button = '1'
          // console.log(this.formData1.dataMap, this.formData1.button)
          this.HandleForm = true
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    // 公众信息采集表单-判定虚假信息
    determine(form) {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })
      this.form.gWhether = '2'
      // console.log(this.form)
      tzzNoSh({ gInstId: this.form.gInstId, gWhether: this.form.gWhether })
        .then((res) => {
          loading.close()
          // console.log(res)
          // this.toBack()
          this.$emit('toBack')
          // this.$emit('toBack')
        })
        .catch((err) => {
          loading.close()
          console.log(err)
        })
    },
    // 公众信息采集表单-属实，现场核实
    trueDeal(form) {
      this.$parent.infoform = 'PatrolProblem'
      this.form.gWhether = '1'
      // console.log(this.form)
      // this.gWheth(this.form)
    },
    gWheth(form) {
      console.log(form)
      this.form.button = '2'
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })
      tzzCommonSubmit(form)
        .then((res) => {
          loading.close()
          // console.log(res)
          // this.form = res.data[0]
          // console.log(this.form)
          this.jbTable = false
          this.$emit('toBack')
          location.reload()
        })
        .catch((err) => {
          loading.close()
          console.log(err)
        })
    },
    // 巡视问题表单-处理
    dealForm(form) {
      // const loading = this.$loading({
      //   lock: true,
      //   text: 'Loading',
      //   spinner: 'el-icon-loading',
      //   background: 'rgba(0, 0, 0, 0.7)',
      // })

      // this.form.button = '1'
      this.HandleForm = true
      // console.log(this.form)
      // this.gWheth(this.form)

      // console.log(this.form)
      this.formData1 = this.form

      // tzzCommonSubmit({ gInstId: this.form.gInstId, gTmpId: this.gTmpId })
      //   .then((res) => {
      //     loading.close()
      //     // console.log(res)
      //     this.formData1 = res.data[102][0]
      //     // console.log(formData1)

      //     this.jbTable = false
      //   })
      //   .catch((err) => {
      //     loading.close()
      //     console.log(err)
      //   })

      // this.$refs[form].validate((valid) => {
      //   if (valid) {
      //     // console.log(this.form)
      //     const loading = this.$loading({
      //       lock: true,
      //       text: 'Loading',
      //       spinner: 'el-icon-loading',
      //       background: 'rgba(0, 0, 0, 0.7)',
      //     })
      //     tzzCommonSubmit(this.form)
      //       .then((res) => {
      //         loading.close()
      //         this.$message({
      //           message: res.message,
      //           type: 'success',
      //         })
      //       })
      //       .catch((err) => {
      //         console.log(err)
      //       })
      //   } else {
      //     console.log('error submit!!')
      //     return false
      //   }
      // })
    },
    dealPassForm(form) {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })

      // this.form.button = '1'
      this.form.dataMap = 'Y'
      // this.HandleForm = true
      // console.log(this.form)
      // this.gWheth(this.form)

      // console.log(this.form)
      this.formData1 = this.form

      this.formData1.dataMap = { pass: 'Y' }
      setDispose(this.formData1)
        .then((res) => {
          loading.close()
          this.$message({
            message: res.message,
            type: 'success',
          })
          //   console.log(res)
          this.$emit('toBack')
          this.shFormData = {}
          if (this.activeName === 'second') {
            location.reload()
          }
        })
        .catch((err) => {
          loading.close()
          console.log(err)
        })
    },
    ZDdeal(form) {
      this.HandleForm1 = true

      // console.log(this.form)
      // this.formData1 = this.form
    },
    zdSubmit(zdFormData) {
      // this.$refs[zdFormData].validate((valid) => {
      //   if (valid) {
      //   console.log(this.shFormData)
      //
      // this.zdFormData.frequency = this.form.gFrequency

      // console.log(this.formData, this.form)
      Object.assign(this.zdFormData, this.form)

      if (this.formData.gFrequency === null || !this.formData.gFrequency) {
        this.zdFormData.frequency = 0
        // console.log(this.zdFormData.gFrequency)
      }
      this.zdFormData.dataMap = { pass: 'DOWN' }
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })

      // console.log(this.zdFormData)

      setGuide(this.zdFormData)
        .then((res) => {
          loading.close()
          this.$message({
            message: res.message,
            type: 'success',
          })
          //   console.log(res)
          if (this.activeName === 'second') {
            location.reload()
          }
          this.$emit('toBack')
        })
        .catch((err) => {
          loading.close()
          console.log(err)
        })

      //   }
      // })
    },
    Handle() {
      this.form = {}
      this.HandleForm = false
    },
    // 巡视问题表单-上报
    report(form) {
      // console.log(this.form)
      if (this.activeName === 'first') {
        this.gWheth(this.form)
      } else if (
        this.activeName === 'second' ||
        this.activeName === 'fourth' ||
        this.activeName === 'third'
      ) {
        this.form.button = '2'
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)',
        })
        this.form.dataMap = { pass: 'UP' }
        setTask(this.form)
          .then((res) => {
            loading.close()
            // console.log(res)
            this.$message({
              message: res.message,
              type: 'success',
            })
            // this.form = res.data[0]
            // console.log(this.form)
            // this.jbTable = false
            location.reload()
            if (this.activeName === 'second') {
              location.reload()
            }
          })
          .catch((err) => {
            loading.close()
            console.log(err)
          })
      }
      this.$emit('toBack')
      this.$emit('toBack')
    },
    report0(form) {
      this.$refs[form].validate((valid) => {
        if (valid) {
          this.form.button = '2'
          // console.log(form)
          // this.form.dataMap = { pass: 'UP' }
          const loading = this.$loading({
            lock: true,
            text: 'Loading',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)',
          })
          tzzPatrolSave(this.form)
            .then((res) => {
              loading.close()
              // console.log(res)
              this.$message({
                message: res.message,
                type: 'success',
                duration: '6000',
              })
              this.form = {}
              this.$router.push({ path: '/dailyOffice' })
            })
            .catch((err) => {
              loading.close()
              console.log(err)
            })
        } else {
          return false
        }
      })
    },
    //   监听处理期限切换
    gTimelimitChange() {
      if (this.form.gTimelimit === '1') {
        this.form.gDueTime = this.afterDays(3)
      } else if (this.form.gTimelimit === '2') {
        this.form.gDueTime = this.afterDays(5)
      } else if (this.form.gTimelimit === '3') {
        this.form.gDueTime = this.afterDays(10)
      }
    },
    // //计算days天后的日期
    afterDays(num) {
      // 设置日期，当前日期的前num天
      //   let myDate = new Date('2021-03-27') // 获取今天日期
      let myDate = new Date() // 获取今天日期
      //   myDate.setDate(myDate.getDate() - (num - 1))
      myDate.setDate(myDate.getDate() + num)
      let dateArray = []
      let myMonth = myDate.getMonth() + 1
      if (myMonth >= 1 && myMonth <= 9) {
        myMonth = '0' + myMonth
      }
      let myDates = myDate.getDate()
      if (myDates >= 0 && myDates <= 9) {
        myDates = '0' + myDates
      }
      let dateTemp
      let flag = 1
      for (let i = 0; i < num; i++) {
        dateTemp = myDate.getFullYear() + '-' + myMonth + '-' + myDates
        dateArray.push(dateTemp)
        myDate.setDate(myDate.getDate() + flag)
      }
      return dateArray[0]
    },
  },
}
</script>

<style scoped lang="scss">
</style>
